#include<iostream>
#include<cmath>
using namespace std;
int main()
{int f(int m);
 int n,a[10000],zuidazhishu=0;int max=0;
 cin>>n;
 for(int i=1;i<=n;i++)
    {
     cin>>a[i];
     if(f(a[i])&&a[i]>max)    {max=a[i];zuidazhishu=a[i];continue;}
     for(int j=a[i]/2;j>=1;j--)
        {
             if((a[i]%j==0)&&f(j)&&(j>max))   {max=j;zuidazhishu=a[i];}
        } 
     }
 cout<<zuidazhishu<<endl;
 system("pause");
 return 0;
}




int f(int m)
{if(m==1)  return 0;
 int j=2;
 double k=sqrt((double) m);
 while(m%j!=0&&j<=k)
   j++;
 if(j>k)    return 1;
 else       return 0;
}
